<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			let pros=[]//省份的数组
			function init(){
				let xhr=new XMLHttpRequest()
				xhr.open("GET","city.json",false)
				xhr.send()
				
				let data=xhr.responseText//以纯文本的方式来接收
				pros=JSON.parse(data)
				let p = document.getElementById("p")//页面上省的下拉列表
				let c = document.getElementById("c")//市的下拉列表
				for (let i = 0; i < pros.length; i++) {
					p.options[i]=new Option(pros[i].name)
				}
				for (let i = 0; i < pros[0].cities.length; i++) {
					c.options[i]=new Option(pros[0].cities[i])
				}
				}
		</script>
	</head>
	<body onload="init()">
		请选择：<select id="p"></select >省<select id="c"></select>市
	</body>
</html>
